package com.ygl.common.util;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
 * @Author yanggld
 * @Date 2019/12/16-18:28
 * @Description
 */
public class StringUtil {
	public static List<String> splitToList(String value, String separate) {
		if (StringUtils.isEmpty(value)) {
			return null;
		}

		String[] valueArray = StringUtils.split(value, separate);

		return Arrays.asList(valueArray);
	}

	public static String simulateText(String value, int size, String padValue) {
		return StringUtils.rightPad(value, size, padValue);
	}

	public static String simulateText(int size) {
		return simulateText("10", size, "10");
	}

	public static String toDisplaySize(String value) {
		return FileUtils.byteCountToDisplaySize(value.length());
	}
}